package com.anolesoft.yr.mbus.code.service.gene;

import org.springframework.beans.BeanUtils;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * @author zhj
 * @date 2020/9/23 19:57
 */
@FunctionalInterface
public interface GeneCodeService {
    String getCode();

    static String execute(String className){
        if(StringUtils.isEmpty(className)){
            return "";
        }else{
            try {
                Class<?> aClass  = Class.forName(className);
                //CodeGenerator codeGenerator = ((CodeGenerator) aClass.newInstance());//BeanUtils.instantiateClass(aClass, CodeGenerator.class);

                GeneCodeService codeGenerator = BeanUtils.instantiateClass(aClass, GeneCodeService.class);
                return codeGenerator.getCode();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        return "";
    }
}
